package org.groupg.mockdatabyspring.system.model;

import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.groupg.mockdatabyspring.system.model.enums.ResultStatus;

/**
 * http 请求的返回值
 */
@Getter
@Setter
public class ResultBody {

    /**
     * 请求状态 {@link ResultStatus}
     */
    private String resultStatus = "";

    /**
     * 请求结果内容
     */
    private String resultMsg = "";

    /**
     * 默认的创造行数
     *
     * @param resultStatus 请求状态 {@link ResultStatus}
     * @param resultMsg    请求结果内容
     */
    public ResultBody(String resultStatus, String resultMsg) {
        this.resultStatus = resultStatus;
        this.resultMsg = resultMsg;
    }

    /**
     * 基础创造函数
     */
    public ResultBody() {
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

        if (o == null || getClass() != o.getClass()) return false;

        ResultBody that = (ResultBody) o;

        return new EqualsBuilder().append(getResultStatus(), that.getResultStatus()).append(getResultMsg(), that.getResultMsg()).isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37).append(getResultStatus()).append(getResultMsg()).toHashCode();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("resultStatus", resultStatus)
                .append("resultMsg", resultMsg)
                .toString();
    }
}
